<?php
class Controller_API_Region extends Controller
{
    public function __construct ($req, $res)
    {
        parent::__construct($req, $res);
        $this->_post = $this->request->post();
    }

    public function action_options ()
    {
        $value = Arr::get($this->_post, 'value', 0);
        $opts  = App_Region::optionsByParentId($value);
        $html  = '';

        foreach ($opts as $rs)
        {
            $id = $rs['id'];
            $name = $rs['name'];

            $html .= '<option value="'.$id.'">'.$name.'</option>';
        }

        $ret = array('status' => 0, 'html' => $html);
        echo json_encode($ret);
    }

}
